package protocol.SZ_2021;

import java.util.HashMap;

public class Handle2021SZ88 implements IHandle2021SZ {
    @Override
    public String handle(SZ_2021Cmd cmd) {
        byte subOrder = cmd.subOrder();

        switch (subOrder){
            case 0x01:
                return handle8801(cmd);
            case 0x02:
                return handle8802(cmd);
            case 0x03:
                return handle8803(cmd);
            default:
                return "深标:未匹配的命令字"+(cmd.readOrder()+","+cmd.readSubOrder());
        }
    }

    private String handle8803(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:存储图像上传命令");
        builder.append("\r\n");

        HashMap<Integer,String> list = new HashMap<>();
        list.put(0,"照片");
        list.put(1,"音频");
        list.put(2,"视频");
        builder.append("类型:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        builder.append("文件ID:"+cmd.readInt(4));
        builder.append("\r\n");

        builder.append("起始地址:"+cmd.readInt(4));
        builder.append("\r\n");

        return builder.toString();
    }

    private String handle8802(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:存储图像检索");
        builder.append("\r\n");

        HashMap<Integer,String> list = new HashMap<>();
        list.put(1,"对外摄像头");
        list.put(2,"对内摄像头");

        builder.append("摄像头ID:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        list.clear();
        list.put(0,"进入重车拍照");
        list.put(1,"服务评价拍照");
        list.put(2,"报警拍照");
        list.put(3,"中心主动拍照");
        list.put(4,"车辆点火");
        list.put(5,"司机签到");
        list.put(6,"司机签退");
        list.put(7,"重翻空");
        list.put(8,"司机照片");
        list.put(9,"车门开关");
        list.put(10,"固定间隔自动拍照");
        list.put(11,"紧急预警");
        list.put(12,"超速报警");
        list.put(13,"出城登记");
        list.put(14,"违规运营（不打表营运）");
        list.put(15,"人脸识别拍照（刷脸签到）");
        list.put(16,"SD 卡拔出拍照");
        list.put(17," 终端卡盖开启拍照");
        list.put(18,"GPS 天线故障拍照");
        list.put(19,"动态查岗拍照（动态查岗）");
        list.put(20,"DSM 重度疲劳驾驶报警");
        list.put(21,"DSM 打电话报警");
        list.put(22,"DSM 抽烟报警");
        list.put(23,"DSM 分心驾驶报警");
        list.put(24,"DSM 异常驾驶报警");
        list.put(25,"司机不系安全带报警");
        list.put(26,"乘客不系安全带报警");
        list.put(31,"乘客人脸抓拍照片");
        list.put(32,"客流统计拍照");
        list.put(33,"车牌照片");
        list.put(34,"违章抓拍");
        list.put(35,"急加速报警");
        list.put(36,"急减速报警");
        list.put(37,"暴力驾驶报警");
        list.put(38,"PCW 报警");
        list.put(39,"FCW 报警");
        list.put(40,"LDW 报警");
        list.put(41,"脏话报警");
        list.put(42,"危险语音报警");
        list.put(43,"DSM 轻度疲劳（打哈欠）");
        list.put(44,"运维安装抓拍");
        list.put(45,"视频丢失报警");
        list.put(46,"司机未戴口罩");
        list.put(47,"乘客未戴口罩");

        builder.append("拍照原因："+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        builder.append("起始时间："+cmd.readBCD(6));
        builder.append("\r\n");
        builder.append("结束时间："+cmd.readBCD(6));
        builder.append("\r\n");
        return builder.toString();
    }

    private String handle8801(SZ_2021Cmd cmd) {
        StringBuilder builder = new StringBuilder();
        builder.append("平台->终端:摄像头立即拍摄命令");
        builder.append("\r\n");
        HashMap<Integer,String> list = new HashMap<>();
        list.put(1,"对外摄像头");
        list.put(2,"对内摄像头");

        builder.append("摄像头ID:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        builder.append("拍摄张数（0为停止拍摄）:"+cmd.readInt(2));
        builder.append("\r\n");

        builder.append("拍照间隔/录像时间（0表示按最小拍照间隔）:"+cmd.readInt(2));
        builder.append("\r\n");

        list.clear();
        list.put(0,"实时上传");
        list.put(1,"保存");
        builder.append("保存标志:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        list.clear();
        list.put(0,"320*240");
        list.put(1,"640*480");
        list.put(2,"800*600");
        list.put(3,"1024*768");
        list.put(4,"1280*720");
        list.put(5,"1920*1080");

        builder.append("分辨率:"+list.getOrDefault(cmd.readInt(1),"未定义"));
        builder.append("\r\n");

        builder.append("图像/视频质量（1～10，1最好）:"+cmd.readInt(1));
        builder.append("\r\n");

        builder.append("亮度（0～255）:"+cmd.readInt(1));
        builder.append("\r\n");
        builder.append("对比度（0～127）:"+cmd.readInt(1));
        builder.append("\r\n");
        builder.append("饱和度（0～127）:"+cmd.readInt(1));
        builder.append("\r\n");
        builder.append("色度（0～255）:"+cmd.readInt(1));
        builder.append("\r\n");


        return builder.toString();
    }

}
